

curr = 0


# 删除第 n 个节点，并返回删除节点后的链表的头节点
def remove_Nth(head, n):
    if head is None:
        return None
    global curr
    curr += 1
    if curr == n:
        return head.next
    ret = remove_Nth(head.next, n)
    head.next = ret
    return head


# 删除倒数第 n 个节点，并返回删除节点后的链表的头节点
def remove_Nth_from_end(head, n):
    if head is None:
        return None

    ret = remove_Nth_from_end(head.next, n)
    head.next = ret

    global curr
    curr += 1
    if curr == n:
        return head.next
    return head